{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5dfd6151",
   "metadata": {},
   "source": [
    "* 时间：2022-11-23 week14\n",
    "* 内容：函数与模块\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba454616",
   "metadata": {},
   "source": [
    "## 1.函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3c3555da",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user():\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a2b747ed",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "greet_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "39425014",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user(username):\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello \", username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "49973151",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello  李华\n"
     ]
    }
   ],
   "source": [
    "greet_user(username=\"李华\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de2d7c8a",
   "metadata": {},
   "source": [
    "# 函数的意义\n",
    "1.重复使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "952211e6",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character '，' (U+FF0C) (Temp/ipykernel_14948/768069149.py, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"C:\\Users\\1\\AppData\\Local\\Temp/ipykernel_14948/768069149.py\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m    def NFU_NEWS_URL(分类，页码):\u001b[0m\n\u001b[1;37m                       ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character '，' (U+FF0C)\n"
     ]
    }
   ],
   "source": [
    "## 实践：广州南方学院新闻网站url实践函数\n",
    "def NFU_NEWS_URL(分类，页码):\n",
    "    \"\"\"广州南方学院新闻页面URL数据\n",
    "    分类包含：【学校要闻：xxyw，校园动态：xydt】\n",
    "    \"\"\"\n",
    "    for i in range(页码):\n",
    "        print(\"https://www.nfu.edu.cn/\" + 分类 + \"/index\"+str(i) +\".htm\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "6c432b4b",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'colloge_url_crawl'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_14948/2350934849.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mcolloge_url_crawl\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'colloge_url_crawl'"
     ]
    }
   ],
   "source": [
    "import colloge_url_crawl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ee529e51",
   "metadata": {},
   "outputs": [],
   "source": [
    "help()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
